package com.javalong.mir.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.javalong.mir.service.BannerService;
import com.javalong.mir.service.MediaService; 
@Controller
@RequestMapping("/")
public class HomeController {
	
	@Autowired
	private BannerService bannerService;
	
	@Autowired
	private MediaService mediaService;
	
	@RequestMapping("")
	public ModelAndView index(ModelAndView modelAndView){
		modelAndView.setViewName("main");
		modelAndView.addObject("banner",bannerService.getLastBanner());
		modelAndView.addObject("mediaList", mediaService.getList(0, 2000));
		return modelAndView;
	}
	
	@RequestMapping("introduce")
	public ModelAndView introduce(ModelAndView modelAndView){
		modelAndView.setViewName("introduce");
		return modelAndView;
	}
	
	@RequestMapping("contact")
	public ModelAndView contact(ModelAndView modelAndView){
		modelAndView.setViewName("contact");
		return modelAndView;
	}
	
	@RequestMapping("case")
	public ModelAndView caseInfo(ModelAndView modelAndView){
		modelAndView.setViewName("case");
		modelAndView.addObject("banner",bannerService.getLastBanner());
		modelAndView.addObject("mediaList", mediaService.getList(0, 2000));
		return modelAndView;
	}

}
